﻿using MediatR;
using RBAC.Common.Domains.RabbitProject;
using RBAC.Common.Dto;
using RBAC.Common.infrastructures.interfaces;
using RBAC.Enum;

namespace RBAC.api.Application.commond.culture
{
    public class CutlerRevealImagesHander : IRequestHandler<CutlerRevealImagesCommond, Rulst>
    {

        private readonly IbaseRpository<ProductionPutImages> _ProductionPutImage;

        public CutlerRevealImagesHander(IbaseRpository<ProductionPutImages> productionPutImage)
        {
            _ProductionPutImage = productionPutImage;
        }

        public async Task<Rulst> Handle(CutlerRevealImagesCommond request, CancellationToken cancellationToken)
        {

            var query = new Rulst() { Code = (int)Reult.success };

            var gh = Typenum.产品检验报告;
            var list = new ProductionPutImages()
            {
                Stypeid = gh,
                ProDuctionBasicid = request.ProDuctionBasicid,
                PutImages = request.GETNEWimages,
                Putid = 0,
            };

            var gett=_ProductionPutImage.Query().Where(x=>x.ProDuctionBasicid==request.ProDuctionBasicid).ToList();

            if(gett.Count<6)
            {
                var result = _ProductionPutImage.Add(list);

                if (result != null)
                {
                    query.data = result;
                    query.MSG = "图片添加成功";
                }
            }
            else
            {
                query.data = -7;

            }


          


            return query;

        }
    }
}
